#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

const int maxn=50, mods=998244353;

ll qpower(ll a, int n) {
  ll s=1;
  for (; n>1; n>>=1) {
    if (n&1) {
      s = s*a%mods;
    }
    a = a*a%mods;
  }
  return s*a%mods;
}

class Matrix {
public:
  int n, m;
  ll v[maxn+1][maxn+1];

  void swapCol(int x, int y) {
    int t;
    for (int i=0; i<m; i++) {
      t=v[x][i], v[x][i]=v[y][i], v[y][i]=t;
    }
  }

  void decCol(int x, int y, ll t) {
    for (int i=0; i<m; i++) {
      v[y][i] = (v[y][i]+mods-v[x][i]*t%mods)%mods;
    }
  }

  void dec(Matrix &b) {
    for (int i=0; i<n; i++) {
      for (int j=0; j<m; j++) {
        v[i][j] = (v[i][j]+mods-b.v[i][j])%mods;
      }
    }
  }

  int elim() {
    int cnt=0;
    for (int i=0, j; i<n; i++) {
      for (j=i; !v[j][i] && j<n; j++);
      if (j>i && j<n) {
        cnt++;
        swapCol(i, j);
      }
      ll t=qpower(v[i][i], mods-2);
      for (j=i+1; j<n; j++) {
        decCol(i, j, v[j][i]*t%mods);
      }
    }
    return cnt;
  }
};

ll calc(int x, int n, int f[]) {
  static Matrix a, b;
  a.n=b.n=a.m=b.m=n-1;
  memset(a.v, 0, sizeof a.v);
  memset(b.v, 0, sizeof b.v);
  for (int i=0; i<n; i++) {
    if (i<n-1) {
      a.v[i][i] = (a.v[i][i]+(n-1)*x%mods)%mods;
      for (int j=0; j<n-1; j++) {
        if (j!=i) {
          b.v[i][j] = (b.v[i][j]+x)%mods;
        }
      }
    }

    if (i<n-1) {
      a.v[i][i] = (a.v[i][i]+mods-x+1)%mods;
      if (f[i]<n-1) {
        b.v[i][f[i]] = (b.v[i][f[i]]+mods-x+1)%mods;
        b.v[f[i]][i] = (b.v[f[i]][i]+mods-x+1)%mods;
      }
    }
    if (f[i]<n-1) {
      a.v[f[i]][f[i]] = (a.v[f[i]][f[i]]+mods-x+1)%mods;
    }
  }

  a.dec(b);
  ll ret = a.elim()%2 ? -1 : 1;
  for (int i=0; i<n-1; i++) {
    ret = ret*a.v[i][i]%mods;
  }
  return ret;
}

int main() {
  freopen("kaisou.in", "r", stdin);
  freopen("kaisou.out", "w", stdout);

  static int f[maxn+1];
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i=1; i<=n; i++) {
    scanf("%d", f+i);
  }

  static Matrix mat;
  mat.n = n, mat.m = n+1;
  for (int i=1; i<=n; i++) {
    mat.v[i-1][0] = 1;
    for (int j=1; j<n; j++) {
      mat.v[i-1][j] = mat.v[i-1][j-1]*i%mods;
    }
    mat.v[i-1][n] = calc(i, n, f);
  }

  static ll g[maxn+1];
  mat.elim();
  for (int i=n-1; i>=0; i--) {
    g[i] = mat.v[i][n]*qpower(mat.v[i][i], mods-2)%mods;
    for (int j=i-1; j>=0; j--) {
      mat.v[j][n] = (mat.v[j][n]+mods-mat.v[j][i]*g[i]%mods)%mods;
      mat.v[j][i] = 0;
    }
  }

  ll ans=0;
  for (int i=0; i<=k; i++) {
    ans = (ans+g[i])%mods;
  }
  printf("%lld", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
